package com.hanbitexam.dao;

import java.io.Reader;
import java.util.List;

import com.hanbitexam.vo.QuestionVo;
import com.hanbitexam.vo.TestVo;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class TestDao {
	private static SqlMapClient sqlmapper;
	List<QuestionVo> list;
	static{
		try{			
			
			Reader reader = Resources.getResourceAsReader("com/hanbitexam/sqlMap/sqlMapConfig.xml");
			sqlmapper = SqlMapClientBuilder.buildSqlMapClient(reader);
			reader.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public static List selectAllTest() throws Exception{
		return sqlmapper.queryForList("selectAllTest");		
	}
	public static String selectAllTestExam(int idx)throws Exception{
		return (String)sqlmapper.queryForObject("selectAllTestExam",idx);
	}
	public static void deleteTest(int idx)throws Exception{
		sqlmapper.delete("deleteTest", idx);
	}
	public static void updateExamDel(TestVo vo)throws Exception{
		sqlmapper.update("updateExamDel", vo);
	}
	public static List selectAllTest(String testname) throws Exception{
		return sqlmapper.queryForList("selectAllTestSearch",testname);		
	}	
	public static void insertTest(TestVo vo)throws Exception{
		sqlmapper.insert("insertTest", vo);
	}
	public static void updateTest(TestVo vo)throws Exception{
		sqlmapper.insert("updateTest", vo);
	}
	
}